package gof23.create.singleton;

/**
 * 懒汉双重校验（线程安全）模式
 * @author zhiyizha
 *
 */
public class SafeSingleton {

	private static volatile SafeSingleton singleton;

    private SafeSingleton() {
    }

    public static SafeSingleton getSingleton() {
        if (singleton == null) {
            synchronized (SafeSingleton.class) {
                if (singleton == null) {
                    singleton = new SafeSingleton();
                }
            }
        }
        return singleton;
    }
}
